You can use the pubprn.vbs script to publish printers
to Active Directory. pubprn.vbs is located in the
c:\windows\system32\printing_admin_scripts\en-us folder.
Tip
For installations outside the U.S., you might not
have the en-us folder. However, you can locate the pubprn.vbs file with
this command from the root of C: dir pubprn.vbs /s.
The basic syntax is
[cscript]
c:\windows\system32\printing_admin_scripts\en-us\pubprn.vbs
[server | UNC-printer-path]"LDAP://DN"
The following table describes the different elements of the pubprn.vbs script.
pubprn Syntax Element | Comments |
---|
| cscript
is the command-based script host used to execute the pubprn.vbs script
file. When used, the output goes to the command prompt. If omitted, the
output shows in dialog boxes.
Tip
While cscript is sometimes optional
when running scripts from the command prompt, you should use it to get
consistent results with the printer scripts. Some scripts run without it
but other scripts do not.
|
c:\windows\system32\
printing_admin_scripts\
en-us
| This is the path to the folder holding the pubprn.vbs file.
Note
Because this path is not known to Windows by default, you either need to
include the path in the command or change the directory before
executing the command. For example, you can change to the directory with
the following command: cd \windows\system32\printing_admin_scripts\en-us.
|
Server | UNC-printer-
path
| This
is the name of a print server sharing one or more printers. If you omit
the server name, the local computer is used. The Universal Naming
Convention (UNC) path can be used to point to a specific printer on a
server. If the UNC isn’t used, the command uses all shared printers on
the target server.
Note
UNC paths have the format of \\server-name\share-name. In this case, the format is \\server-name\shared-printer-name.
|
| LDAP:// must be entered exactly and with LDAP in uppercase.
Tip
This is one of the few times when the case of the command matters.
|
| This
is the distinguished name (dn) of the OU where the printer will be
published. For example, if you want to identify an OU named printers in
the pearson.pub domain, use the following DN:
ou=printers,dc=pearson,dc=pub. The path to the OU must exist or the
command will fail.
|
For example, if you want to publish a single printer
shared as Color_Laser on a server named DC2, in an OU named Printers in
the pearson.pub domain, you can use the following command:
cscript
c:\windows\system32\printing_admin_scripts\en-us\pubprn.vbs
\\dc2\color_laser "LDAP://ou=printers,dc=pearson,dc=pub"
When complete, the command shows the following output:
Published printer: LDAP://DC1.pearson.pub/CN=DC2-Color_Laser,
ou=printers,dc=pearson,dc=pub
Figure 1 shows the printer published into Active Directory Users and Computers from the preceding command.
Tip
The OU must exist in the domain for the command to work. You can add the OU using any method including the dsadd command: dsadd ou ou-dn.
If you want to publish all printers shared on a
server named Print1 in an OU named Printers in the pearson.pub domain,
you can use the following command:
cscript
c:\windows\system32\printing_admin_scripts\en-us\pubprn.vbs dc2
"LDAP://ou=printers,dc=pearson,dc=pub"
You can also publish printers from the printer properties dialog box by selecting List in the Directory, as shown in Figure 2.